package com.qidianit.mes.pro.controller;

import com.github.pagehelper.PageHelper;
import com.qidianit.mes.common.Result;
import com.qidianit.mes.pojo.pro.ProcessStep;
import com.qidianit.mes.pro.service.ProcessStepService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Package Path: com.qidianit.mes.pro.controller
 * Author: Alhz
 * Description:工序步骤
 * Date: 2025/9/17 15:49
 */
@RestController
@RequestMapping("/processStep")
public class ProcessStepController {
    @Autowired
    private ProcessStepService processStepService;

    @GetMapping("/page")
    public Result selectProcessStepListByPage(Long processId,
                                              @RequestParam(defaultValue = "1") int page,
                                              @RequestParam(defaultValue = "10") int pageSize){
        return processStepService.selectProcessStepList(processId,page,pageSize);
    }

    /**
     * 根据步骤编号查询工序步骤
     * @param id
     * @return
     */
    @GetMapping("/get/{id}")
    public Result selectProcessStepById(@PathVariable Long id){
        return processStepService.selectProcessStepById(id);
    }


    /**
     * 新增工序步骤
     * @param processStep
     * @return
     */
    @PostMapping("/add")
    public Result addProcessStep(@RequestBody ProcessStep processStep){
        return processStepService.addProcessStep(processStep);
    }

    /**
     * 更新工序步骤
     * @param processStep
     * @return
     */
    @PutMapping("/update")
    public Result updateProcessStep(@RequestBody ProcessStep processStep){
        return processStepService.updateProcessStep(processStep);
    }

    /**
     * 根据步骤编号删除工序步骤
     * @param stepId
     * @return
     */
    @DeleteMapping("/delete/{id}")
    public Result deleteProcessStepById(@PathVariable("id") Long stepId){
        return processStepService.deleteProcessStepById(stepId);
    }
}
